home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Utilities / Winter Shell 1.0d2 / Source / Libraries / EventLib / EventLib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-13  |  3.4 KB  |  106 lines  |  [TEXT/KAHL]

  1. #pragma once
  2.  
  3. #include "LLPtrLib.h"
  4. #include "MenuLib.h"
  5. #include "TaskLib.h"
  6. #include "TimeLib.h"
  7.  
  8. /* data about an object (usually a pointer or handle to the object)
  9.     that can receive events */
  10. typedef void *EventObjectType;
  11. typedef long EventIDType;
  12.  
  13. /* functions to execute for events */
  14. typedef struct {
  15.  
  16.     /* handlers called only for the focus object */
  17.     struct {
  18.         void (*idle)(EventObjectType object);
  19.         void (*keydown)(EventObjectType object, EventRecord *event);
  20.         Boolean (*menu)(EventObjectType object, const MenuPickType *pick);
  21.         void (*adjustmenu)(EventObjectType object);
  22.     } focusObject;
  23.  
  24.     /* handlers called for objects in the focus window */
  25.     struct {
  26.         void (*prefilter)(EventObjectType object, EventRecord *event);
  27.         void (*postfilter)(EventObjectType object, EventRecord *event);
  28.         void (*focus)(EventObjectType object, Boolean focus);
  29.         void (*selectall)(EventObjectType object);
  30.         void (*clicked)(EventObjectType object, EventObjectType clickedObject, EventIDType clickedID);
  31.         Boolean (*within)(EventObjectType object, Point where);
  32.         Boolean (*mousedown)(EventObjectType object, EventRecord *event);
  33.         Boolean (*adjustcursor)(EventObjectType object, Point where, RgnHandle cursor);
  34.         TicksType (*adjustsleep)(EventObjectType object);
  35.     } focusWindow;
  36.  
  37.     /* handlers called for all objects in a window */
  38.     struct {
  39.         void (*resize)(EventObjectType object, short dh, short dv);
  40.         void (*grow)(EventObjectType object, Rect *size);
  41.         void (*zoom)(EventObjectType object, short *width, short *height);
  42.         void (*update)(EventObjectType object);
  43.         void (*activate)(EventObjectType object, Boolean activate);
  44.         void (*close)(EventObjectType object);
  45.     } window;
  46.     
  47.     /* handlers called for each object type */
  48.     struct {
  49.         Boolean (*menu)(const MenuPickType *pick);
  50.         void (*adjustmenu)(void);
  51.         void (*memorylow)(void);
  52.         void (*suspend)(void);
  53.         void (*resume)(void);
  54.     } objectType;
  55.     
  56. } EventTableType;
  57.  
  58. /* structure of an object that responds to events */
  59. typedef struct EventType {
  60.     LLType next;                        /* next object in list */
  61.     EventIDType id;                    /* object's id */
  62.     EventObjectType object;            /* the object */
  63.     const EventTableType    *table;    /* event handlers */
  64. } EventType;
  65.  
  66. /* globals */
  67. extern Boolean gInBackground;        /* true if application is in the background */
  68.  
  69. /* event table */
  70. void EventTableRegister(const EventTableType *table);
  71.  
  72. /* accessing the focus object and focus window */
  73. Boolean EventValid(EventType *event);
  74. void FocusSet(EventObjectType object);
  75. void FocusWindowSet(WindowPtr window);
  76. WindowPtr FocusWindow(void);
  77. EventType *FocusList(void);
  78. EventObjectType FocusObject(void);
  79. EventIDType FocusID(void);
  80. const EventTableType *FocusTable(void);
  81.  
  82. /* executing events */
  83. void EventMenu(const MenuPickType *pick);
  84. void EventAdjustMenu(void);
  85. void EventFocus(EventType *focus, Boolean flag);
  86. void EventActivate(WindowPtr window, Boolean activate);
  87. void EventExecute(EventRecord *event);
  88. void EventOne(void);
  89. void EventLoop(void);
  90. void EventLoopMain(void);
  91.  
  92. /* utilities */
  93. Boolean EventInBackground(void);
  94. Boolean EventInAppleEvent(void);
  95. void EventLoopExit(Boolean flag);
  96. void EventInteractWithUser(void);
  97. Boolean EventGet(short mask, EventRecord *event, TicksType sleep, RgnHandle cursor);
  98.  
  99. /* event tasks */
  100. TaskHandle EventPreTaskInsert(TaskActionType action, void *data);
  101. TaskHandle EventPostTaskInsert(TaskActionType action, void *data);
  102. void EventPreTaskDelete(TaskHandle task);
  103. void EventPostTaskDelete(TaskHandle task);
  104. void EventPreTasksExecute(void);
  105. void EventPostTasksExecute(void);
  106.